﻿using System;

namespace Red.Controls.ViewModels
{
    public class PendingChangelistInfo
    {
        #region Properties

        public string Description { get; set; }
        public int Id { get; set; }

        #endregion Properties

        #region Public methods

        public override string ToString()
        {
            var shortDescription = Description.Substring( 0, Math.Min( 250, Description.Length ) ).Replace( Environment.NewLine, " " );
            return string.Format( "{0} {1}", Id, shortDescription );
        }

        public override bool Equals( object obj )
        {
            PendingChangelistInfo other = obj as PendingChangelistInfo;

            if( other != null )
            {
                return Id == other.Id;
            }

            return false;
        }

        public override int GetHashCode()
        {
            return Id;
        }

        #endregion Public methods
    }

    public class NewPendingChangelistInfo : PendingChangelistInfo
    {
        #region Public methods

        public override string ToString()
        {
            return "New";
        }

        #endregion Public methods
    }

    public class DefaultChangelistInfo : PendingChangelistInfo
    {
        #region C-tor

        public DefaultChangelistInfo()
        {
            Id = -1;
        }

        #endregion C-tor

        #region Public methods

        public override string ToString()
        {
            return "<default>";
        }

        #endregion Public methods
    }
}